/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.wdm.beans;

import java.util.ArrayList;
import java.util.List;
import org.wdm.beans.points.Point;
import org.wdm.utils.BusUtils;
import org.wdm.utils.Utils;

/**
 *
 * @author thanasis
 */
public class BusStop{
    private String naptan;
    private String name;
    private Point point;
    private List<Bus> busesList;

    public BusStop() {
        busesList = new ArrayList<Bus>();
    }
    
    public void addBus(Bus bus){
        if(!busesList.contains(bus)){
            busesList.add(bus);
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String Name) {
        this.name = Name;
    }

    public List<Bus> getBusesList() {
        return busesList;
    }

    public void setBusesList(List<Bus> busesList) {
        this.busesList = busesList;
    }

    public String getNaptan() {
        return naptan;
    }

    public void setNaptan(String naptan) {
        this.naptan = naptan;
    }

    public Point getPoint() {
        return point;
    }

    public void setPoint(Point point) {
        this.point = point;
    }

    @Override
    public String toString() {
        return "lat=" + point.getLatitude() + ", long=" + point.getLongitude() + ", naptan=" + naptan + ", Name=" + name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final BusStop other = (BusStop) obj;
        if (!this.naptan.equals(other.naptan)) {
            return false;
        }
        return true;
    }

    public int hashCode() {
        int hash = 7;
        hash = 29 * hash + (this.naptan != null ? this.naptan.hashCode() : 0);
        return hash;
    }

    
    public double getDistance(Point point, String unit){
        return Utils.distance(this.point.getLatitude(), this.point.getLongitude(), point.getLatitude(), point.getLongitude(), unit);
    }
    
    public double getDistance(double lat, double lon, String unit){
        return Utils.distance(this.point.getLatitude(), this.point.getLongitude(), lat, lon, unit);
    }
}
